package com.example.campuslink.commen.db.userInfo

import androidx.room.Entity
import androidx.room.Ignore
import java.io.Serializable

@Entity(tableName = "user_info_table", primaryKeys = ["id", "userNumber"])
data class UserInfoTable(
    var id: Int = 0,
    var userNumber: String = "",
    //用户名
    var userName: String = "",
    //用户头像
    var userAvatar: String = "",
    //用户简介
    var userIntro: String = "",
    //用户性别
    var userGender: String = ""
): Serializable {
    @Ignore
    constructor() : this(
        id = 0,
        userNumber = "",
        userName = "",
        userAvatar = "",
        userIntro = "",
        userGender = ""
    )

    companion object {
        suspend fun insertWithId(
            dao: UserInfoDao,
            comment: UserInfoTable
        ) {
            val maxId = dao.getMaxId() ?: 0
            dao.insertUserInfo(comment.copy(id = maxId + 1))
        }
    }
}
